package cn.tedu.spring.life;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * BeanPostProcessor Bean的后置处理器，在创建了Bean对象之后执行，对对象进行了一系列的处理
 * postProcessBeforeInitialization Bean的前置处理
 * postProcessAfterInitialization Bean的后置处理
 */
@Component
public class MyBPP implements BeanPostProcessor {

    @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("前置处理："+beanName);
        return bean;
    }

    @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("后置处理："+beanName);
        return bean;
    }
}
